﻿--
--
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'spZeusPickingQuantity' AND type = 'P')
BEGIN
  DROP PROCEDURE spZeusPickingQuantity
END
GO

-- HU - Mennyiség módosítás
-- EN - Update picked quantity
--
CREATE PROCEDURE spZeusPickingQuantity
(@AccessToken INTEGER, @ItemID NVARCHAR(20), @Quantity DECIMAL(18,6))
 AS
BEGIN
  DECLARE
    @Err INTEGER,
    @Rows INTEGER,
    @UserID INTEGER,
    @Lang NVARCHAR(10)

  EXEC @Err = spAccessTokenCheck @AccessToken, @UserID OUTPUT, @Lang OUTPUT

  IF (@Err != 0)
    GOTO __ERROR__
    
  --
  --
  IF (@Quantity < 0) BEGIN

    IF (@Lang = 'HU')
      RAISERROR (N'Mennyiség nem lehet negatív !', 16, 1)

    IF (@Lang = 'EN')
      RAISERROR (N'Quantity could not benn less than Zero !', 16, 1)

    IF (@Lang = 'DE')
      RAISERROR (N'Menge kann nicht negativ sein !', 16, 1)

    GOTO __ERROR__
  END

  -- HU - Mennyiség módosítás
  -- EN - Change picked quantity
  --
  BEGIN TRY

    UPDATE ZeusPickingItem
       SET PickedQua = @Quantity
     WHERE ID = @ItemID

  END TRY
  BEGIN CATCH

  END CATCH

    
-- Well done.
--
  RETURN(0)

-- We have a problem !
--
__ERROR__:
  RETURN(1)
END
GO
